mapseq is package{
  -- test out type inference over sequences
  
  contract mmap over %%s is {
    mapseq has type for all %e,%f such that (%%s of %e,(%e)=>%f) => %%s of %f
  }
  
  implementation mmap over array is {
    mapseq(S, F) is valof{
      var alreadyMapped := sequence of {};
	  var toBeMapped := S;
	  while toBeMapped matches sequence of {X;.. restTBM} do {
	    alreadyMapped := sequence of {alreadyMapped..;F(X)};
	    toBeMapped := restTBM;
	  };
	  valis alreadyMapped;
    };
  }
  
  main() do {
    XX is mapseq(list of {1;2;3}, (function(X) is X*2));
    
    logMsg(info,"XX=$XX");
    
    assert XX = list of {2;4;6};
  }
}  
    